home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #11 / Amiga Plus CD - 2002 - No. 11.iso / Tools / Development / PowerD / powerd / source / ddbg_trace.ass < prev    next >
Text File  |  2002-10-28  |  3KB  |  139 lines

  1. ; Code by Zbigniew `Zeeball` Trzcionkowski
  2. ; At: 19.02.2000
  3. ; Use it for free just credit me!
  4.  
  5. ; 2.6.2002 by Martin <MarK> Kuchinka:
  6. ; small changes to make the code more relevant for PowerD debugger
  7.  
  8.     machine    68010
  9.  
  10. ; Trace(code:a0,test:a1)(pc,reglist)
  11.     xdef    _Trace
  12. _Trace    movem.l    a5-a6,-(a7)
  13.     movea.l    $4.w,a6
  14.     jsr    (-132,a6)        ; Forbid
  15.     jsr    (-$78,a6)        ; Disable
  16.  
  17.     lea    (Trail,pc),a5
  18.     move.l    a0,(-4,a5)
  19.     move.l    a1,(-8,a5)
  20.     jsr    (-30,a6)        ; Supervisor
  21.  
  22.     jsr    (-$7e,a6)        ; Enable
  23.     jsr    (-138,a6)        ; Permit
  24.     movem.l    (a7)+,a5-a6
  25.     move.l    (addy,pc),d0
  26.     lea    (reglist,pc),a0
  27.     move.l    a0,d1
  28.     rts
  29.  
  30.  
  31. test    dc.l    0
  32. Procedura    dc.l    0
  33. Trail    movem.l    d0-a6,-(sp)
  34.  
  35.     ; get vbr 68000-68060 compatible
  36.     suba.l    a1,a1
  37.     movea.l    $4.w,a6
  38.     move.w    ($128,a6),d0    ; ExecBase.AttnFlags
  39.     btst    #0,d0        ; 68010+?
  40.     beq.b    .xvbr
  41.     movec    VBR,a1        ; yes, get VBR
  42. .xvbr
  43.     move.l    ($24,a1),-(sp)
  44.     move.l    a1,-(sp)
  45.  
  46.     lea    (Trailer,pc),a0
  47.     move.l    a0,($24,a1)    ; setup the tracing function
  48.  
  49.     bsr.b    .change_t        ; enable tracing
  50.  
  51.     move.l    (Procedura,pc),a0
  52.     jsr    (a0)        ; run the code
  53.  
  54.     bsr.b    .change_t        ; disable tracing
  55.  
  56.     move.l    (sp)+,a1
  57.     move.l    (sp)+,($24,a1)
  58.     movem.l    (sp)+,d0-a6
  59.     rte
  60.  
  61. ; change the tracing bit
  62. .change_t    move.w    SR,d0
  63.     bchg    #15,d0
  64.     move.w    d0,SR
  65.     rts
  66.  
  67.  
  68.  
  69. ; this function is invoked when an instruction is completed
  70. ; it stores the address of the next instruction to be executed to the addy address
  71. Trailer    movem.l    d0-a6,-(sp)
  72. ;    move.l    _exe,a0
  73. ;    move.l    (62,sp),d0
  74. ;    cmp.l    (16,a0),d0
  75. ;    blt.w    .exit
  76. ;    cmp.l    (20,a0),d0
  77. ;    bge.w    .exit
  78.  
  79. ;    cmp.w    #$00ff,(62,sp)    ; pc, rom area?
  80. ;    blt.w    .maybe
  81. ;    bra.w    .exit
  82. ;.maybe    cmp.w    #$00f0,(62,sp)
  83. ;    blt.w    .exit
  84.  
  85.     move.l    a0,-(a7)        ; save all the registers
  86.     lea    (reglist,pc),a0
  87.     move.l    d0,(a0)
  88.     move.l    d1,(4,a0)
  89.     move.l    d2,(8,a0)
  90.     move.l    d3,(12,a0)
  91.     move.l    d4,(16,a0)
  92.     move.l    d5,(20,a0)
  93.     move.l    d6,(24,a0)
  94.     move.l    d7,(28,a0)
  95.     move.l    (a7)+,(32,a0)
  96.     move.l    a1,(36,a0)
  97.     move.l    a2,(40,a0)
  98.     move.l    a3,(44,a0)
  99.     move.l    a4,(48,a0)
  100.     move.l    a5,(52,a0)
  101.     move.l    a6,(56,a0)
  102.     move.l    usp,a1
  103.     move.l    a1,(60,a0)
  104.     move.w    (60,sp),(64,a0)
  105.  
  106.     move.l    a0,a1
  107.     move.l    (62,sp),a0
  108.     move.l    (test,pc),a2
  109.     jsr    (a2)
  110. ; this returns:
  111. ; 0 - everything is ok
  112. ; 1 - raise
  113.  
  114.     tst.l    d0
  115.     beq.b    .exit
  116.  
  117.     lea    (addy,pc),a0
  118.     move.l    (62,sp),(a0)    ; store pc
  119.  
  120.     ; get vbr 68000-68060 compatible
  121.     suba.l    a1,a1
  122.     movea.l    $4.w,a6
  123.     move.w    ($128,a6),d0    ; ExecBase.AttnFlags
  124.     btst    #0,d0        ; 68010+?
  125.     beq.b    .xvbr
  126.     movec    VBR,a1
  127. .xvbr
  128.     ; now enshort the tracing routine to be as small as possible
  129.     ; by setting the tracing exception vector to rte instruction only
  130.     lea    (ski,pc),a0
  131.     move.l    a0,($24,a1)
  132. .ok
  133. .exit    movem.l    (sp)+,d0-a6
  134. ski    rte
  135.  
  136. addy    dc.l    0
  137. reglist    ds.l    17
  138.     xref    _exe
  139.